import {nav,banner,logoList,shopData,Size,orderList,user} from '../data/index.js'

import Ajax from './index.js'

// 获取到导航栏的数据信息
export const getNavList = (callback) => {return Ajax('nav',{},callback)}

// 获取到轮播图的信息
export const getBanners = (callback) => { return Ajax('banner',{},callback)}

// 获取到log的数据信息
export const getLogic = (id,callback)=> { return Ajax(`fier/${id}`,{},callback)}

// 获取到商品的数据信息
export const getShopList = (id,callback)=>{ return Ajax(`list/${id}`,{},callback)}

//根据商品分类id来进行搜索查询输入的商品名称
export const getSearch = (data,callback) =>{ return Ajax('search',data,callback,"POST")}

//查看商品详细信息
export const getDetail =(id,callback) =>{ return Ajax(`detail/${id}`,{},callback)}

// 获取到鞋子的尺寸数据
export const getSize = (callback)=>{ return Ajax('size',{},callback) }

// 获取到订单栏导航数据
export const getOrderList = ()=>{
	return new Promise((resolve)=>{
		setTimeout(()=>{
			resolve(orderList)
		},300)
	})
}

// 获取到用户信息
export const getUser = (callback)=>{
	let data='123'
	for(let i=0;i<user.length;i++){
		if(user[i].user == callback.user && user[i].pwd == callback.pwd){
			data ={code:'200',msg:'登录成功',data:user[i]}
		}else{
			data = {code:'400',msg:'用户名或者密码错误',data:[]}
		}
	}
	return new Promise((resolve)=>{
		setTimeout(()=>{
			resolve(data)
		},300)
	})
}

// 注册验证
export const VerifyInfo = (id,callback) =>{ return Ajax(`verify/${id}`,{},callback)}

// 用户注册
export const RegIster = (data,callback)=>{ return Ajax('register',data,callback,'POST')}

// 用户登录
export const Lgoin = (data,callback)=>{ return Ajax('login',data,callback,'POST')}


//用户添加对应的地址
export const Address = (data,callback) =>{ return Ajax('address/add',data,callback,'POST')}

// 根据ID来查询对应的用户地址
export const GetAddress = (id,callback) =>{ return Ajax(`address/${id}`,{},callback)}

// 添加用户订单信息
export const AddOrder = (data,callback) =>{ return Ajax('addorder',data,callback,"POST")}

//修改订单状态
export const UpOrder = (id,callback) =>{ return Ajax(`uporder/${id}`,{},callback,"PUT")}